package com.jiang.daily.Q2302;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/04/28 14:17
 */
class Solution {
    public long countSubarrays(int[] nums, long k) {
        long total = 0, res = 0;
        for (int i = 0, j = 0; j < nums.length; j++) {
            total += nums[j];
            while (total * (j - i + 1) >= k) {
                total -= nums[i++];
            }
            res += j - i + 1;
        }
        return res;
    }
}
